
const sumbit = document.querySelector('.sumbit')
sumbit.addEventListener('click', function () {
    let username = document.querySelector('#username')
    let password = document.querySelector('#password')
    username = username.value
    password = password.value
    let boller = false
    let boller2 = false
    let password_t = localStorage.getItem('password')
    let username_t = localStorage.getItem('uname')
    let sum = 0;
    if (username.length != username_t.length) {

    }
    else {

        for (let i = 0; i < username.length; i++) {

            if (username[i] == username_t[i]) {
                sum++
            }
        }
    }
    if (sum == username_t.length) {
        boller = true
    }
    sum = 0;
    if (password.length != password_t.length) {

    }
    else {

        for (let i = 0; i < password.length; i++) {
            if (password[i] == password_t[i]) {
                sum++
            }
        }
    }
    if (sum == password_t.length) {
        boller2 = true
    }
    if (!(boller && boller2)) {
        if (boller == false) {
            alert("用户名错误")
            console.log(boller)
            document.querySelector('#username').placeholder = "用户名错误"
        }
        else {
            let app = new Vue({
                el: "#app",
                data: {
                    boll: false,
                }
            })
            alert("密码错误")
            document.querySelector('#password').placeholder = "密码错误"
        }
        if (boller2) {
            let app2 = new Vue({
                el: "#app2",
                data: {
                    boll2: false,
                }
            })
        }
    }
    if (boller && boller2) {
        alert("登录成功，即将跳转到首页")
        location.href = 'index.html'
        // window.location.href = 'file:///E:/%E6%A1%8C%E9%9D%A2/javascript%E8%AE%BE%E8%AE%A1/denglu.html';
        window.location.href = 'D:\桌面\网页设计5\index.html'
    }
})